package com.ruoyi.canteen.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.canteen.mapper.CanteenNoticeMapper;
import com.ruoyi.canteen.domain.CanteenNotice;
import com.ruoyi.canteen.service.ICanteenNoticeService;

/**
 * 公告Service业务层处理
 * 
 * @author zhangw
 * @date 2021-10-08
 */
@Service
public class CanteenNoticeServiceImpl implements ICanteenNoticeService 
{
    @Autowired
    private CanteenNoticeMapper canteenNoticeMapper;

    /**
     * 查询公告
     * 
     * @param id 公告主键
     * @return 公告
     */
    @Override
    public CanteenNotice selectCanteenNoticeById(Long id)
    {
        return canteenNoticeMapper.selectCanteenNoticeById(id);
    }

    /**
     * 查询公告列表
     * 
     * @param canteenNotice 公告
     * @return 公告
     */
    @Override
    public List<CanteenNotice> selectCanteenNoticeList(CanteenNotice canteenNotice)
    {
        return canteenNoticeMapper.selectCanteenNoticeList(canteenNotice);
    }

    /**
     * 新增公告
     * 
     * @param canteenNotice 公告
     * @return 结果
     */
    @Override
    public int insertCanteenNotice(CanteenNotice canteenNotice)
    {
        canteenNotice.setCreateTime(DateUtils.getNowDate());
        return canteenNoticeMapper.insertCanteenNotice(canteenNotice);
    }

    /**
     * 修改公告
     * 
     * @param canteenNotice 公告
     * @return 结果
     */
    @Override
    public int updateCanteenNotice(CanteenNotice canteenNotice)
    {
        return canteenNoticeMapper.updateCanteenNotice(canteenNotice);
    }

    /**
     * 批量删除公告
     * 
     * @param ids 需要删除的公告主键
     * @return 结果
     */
    @Override
    public int deleteCanteenNoticeByIds(Long[] ids)
    {
        return canteenNoticeMapper.deleteCanteenNoticeByIds(ids);
    }

    /**
     * 删除公告信息
     * 
     * @param id 公告主键
     * @return 结果
     */
    @Override
    public int deleteCanteenNoticeById(Long id)
    {
        return canteenNoticeMapper.deleteCanteenNoticeById(id);
    }

    /**
     * 查询最新一条公告信息
     * 门店ID为空时，显示首页公告信息
     * @param mdId 门店ID
     * @return
     */
    @Override
    public CanteenNotice selectCanteenNoticeLastOne(Long mdId){
        return canteenNoticeMapper.selectCanteenNoticeLastOne(mdId);
    }
}
